Skip to content

feat: add Grok 4.5 model support and fix xAI reasoning format#867

Open
navedmerchant wants to merge 1 commit into
mainfrom
feat/grok-4.5-support
Open

feat: add Grok 4.5 model support and fix xAI reasoning format#867
navedmerchant wants to merge 1 commit into
mainfrom
feat/grok-4.5-support

Conversation

@navedmerchant

@navedmerchant navedmerchant commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #866

Description

Grok 4.5 was publicly released on July 9, 2026 as xAI's new flagship model. This PR adds support for it in the xAI provider and fixes a latent reasoning format bug.

Key implementation details:

  1. New model definition (packages/types/src/providers/xai.ts): Added grok-4.5 with 500K context window, $2.00/$6.00 input/output pricing, $0.50 cache pricing, and configurable reasoning effort (["low", "medium", "high"], default "high"). Updated xaiDefaultModelId from grok-4.20 to grok-4.5.

  2. Reasoning format bug fix (src/api/providers/xai.ts): The xAI Responses API expects reasoning: { effort: "high" } format, but the handler was passing reasoning: { reasoning_effort: "high" } (Chat Completions format). This was a latent bug that affected grok-3-mini and would have broken grok-4.5's configurable reasoning. The handler now converts from the OpenAI params shape to the Responses API { effort } format.

  3. Test updates (src/api/providers/__tests__/xai.spec.ts): Fixed the existing grok-3-mini reasoning test to expect the correct { effort } format. Added two new tests for grok-4.5 — one verifying default high reasoning effort, one verifying custom low effort.

  4. E2e test update (apps/vscode-e2e/src/suite/providers/xai.test.ts): Updated the primary model ID from grok-4.20 to grok-4.5.

Test Procedure

Unit tests (all passing):

  • cd src && npx vitest run api/providers/__tests__/xai.spec.ts — 17 tests pass (15 original + 2 new grok-4.5 tests)
  • cd src && npx vitest run api/transform/__tests__/model-params.spec.ts api/transform/__tests__/reasoning.spec.ts shared/__tests__/api.spec.ts — 161 tests pass
  • cd src && npx vitest run api/transform/__tests__/openai-format.spec.ts — 56 tests pass
  • cd src && npx vitest run shared/__tests__/ProfileValidator.spec.ts — 28 tests pass
  • cd packages/types && npx vitest run — 230 tests pass

Lint & type-check (pre-commit/pre-push hooks):

  • ESLint passes with --max-warnings=0 across all packages
  • tsc --noEmit passes for @roo-code/types, @roo-code/vscode-e2e, and zoo-code

Pre-Submission Checklist

  • Issue Linked: This PR is linked to issue Add Grok 4.5 model support to xAI provider #866.
  • Scope: My changes are focused on the linked issue (adding grok-4.5 support + fixing the reasoning format bug it exposed).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates required — model definitions are self-documenting via the description field.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A — no UI changes. The new grok-4.5 model will automatically appear in the xAI provider model dropdown.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The reasoning format bug (reasoning_effort vs effort) was pre-existing and would have silently caused grok-4.5 to ignore the user's reasoning effort setting, always falling back to the model's default. The xAI API likely silently ignores unrecognized fields in the reasoning object, so this wouldn't have caused errors — just incorrect behavior.

Get in Touch

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Updated xAI integration to default to grok-4.5 instead of grok-4.20.
    • Reasoning-effort settings are now sent in the format xAI expects, improving consistency of responses.
    • Default reasoning effort is applied when not provided, and custom values are honored.
  • Tests
    • Updated end-to-end and provider tests to validate grok-4.5 plus default and custom reasoning-effort behavior.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f7dbc0d-041b-4e16-8040-7f587d75358e

📥 Commits

Reviewing files that changed from the base of the PR and between eb40ce1 and 99adf9a.

📒 Files selected for processing (4)
  • apps/vscode-e2e/src/suite/providers/xai.test.ts
  • packages/types/src/providers/xai.ts
  • src/api/providers/__tests__/xai.spec.ts
  • src/api/providers/xai.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/types/src/providers/xai.ts
  • src/api/providers/tests/xai.spec.ts
  • apps/vscode-e2e/src/suite/providers/xai.test.ts

📝 Walkthrough

Walkthrough

This PR changes the default xAI model from grok-4.20 to grok-4.5, adds model metadata, maps reasoning settings to the Responses API format, and updates unit and end-to-end test references.

Changes

xAI grok-4.5 model and reasoning fix

Layer / File(s) Summary
Model definition and default id update
packages/types/src/providers/xai.ts
Sets xaiDefaultModelId to grok-4.5 and adds its pricing, context, tool, and reasoning-effort metadata.
Reasoning payload conversion in createMessage
src/api/providers/xai.ts
Maps model.reasoning.reasoning_effort to requestBody.reasoning.effort.
Unit test updates for reasoning format
src/api/providers/__tests__/xai.spec.ts
Updates nested reasoning assertions and tests default high and custom low effort for grok-4.5.
E2E test model reference update
apps/vscode-e2e/src/suite/providers/xai.test.ts
Updates the model constant and interceptor comment from grok-4.20 to grok-4.5.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant XAIHandler
  participant ResponsesAPI
  Caller->>XAIHandler: createMessage with reasoning effort
  XAIHandler->>XAIHandler: Build reasoning.effort payload
  XAIHandler->>ResponsesAPI: Send formatted request
Loading

Possibly related issues

  • Zoo-Code-Org/Zoo-Code issue 866: Directly covers grok-4.5 support, the default-model update, reasoning format correction, and related tests.

Possibly related PRs

Suggested labels: awaiting-review

Suggested reviewers: hannesrudolph, edelauna, jamesrobert20

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding Grok 4.5 support and fixing xAI reasoning formatting.
Description check ✅ Passed The description follows the template well, including the linked issue, change summary, testing steps, checklist, and optional sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/grok-4.5-support

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Add grok-4.5 model definition with 500K context window, .00/.00
input/output pricing, /bin/sh.50 cache pricing, and configurable reasoning
(low/medium/high, default high). Update xaiDefaultModelId from
grok-4.20 to grok-4.5 as the new flagship model.

Fix a latent bug in the xAI handler where reasoning effort was sent in
Chat Completions format (reasoning: { reasoning_effort }) instead of
the Responses API format (reasoning: { effort }). This affected
grok-3-mini and would have broken grok-4.5's configurable reasoning.

Update tests to cover the reasoning format fix and add grok-4.5
reasoning support tests. Update e2e test primary model to grok-4.5.

Fixes #866
@edelauna edelauna force-pushed the feat/grok-4.5-support branch from eb40ce1 to 99adf9a Compare July 16, 2026 13:45

@edelauna edelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked for me:

Image

@edelauna edelauna enabled auto-merge July 16, 2026 13:46
@edelauna edelauna added this pull request to the merge queue Jul 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 16, 2026
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Grok 4.5 model support to xAI provider

3 participants